//
//  ClassifyBarCell.m
//  MyNewProject
//
//  Created by 王春辉 on 2020/1/3.
//  Copyright © 2020年 sun. All rights reserved.
//

#import "ClassifyBarCell.h"

@interface ClassifyBarCell()
@property (nonatomic, strong) UILabel *titleLabel;
@end

@implementation ClassifyBarCell
- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = [UIColor whiteColor];
        self.layer.masksToBounds = true;
        self.layer.borderColor = [UIColor lightGrayColor].CGColor;
        self.layer.borderWidth = 0.38;
        [self initSubViews];
    }
    return self;
}
- (void)layoutSubviews {
    [super layoutSubviews];
    self.layer.cornerRadius = self.height * 0.5;
}
- (void)setSelected:(BOOL)selected {
    UIColor *titleColor = selected ? SKColorWithHex(0xFF3030) : SKColorWithHex(0x333333);
    UIColor *bgColor = selected ? SKColorWithHex(0xFFE5E5) : SKColorWithHex(0xFFFFFF);
    self.titleLabel.backgroundColor = bgColor;
    self.titleLabel.textColor = titleColor;
    [super setSelected:selected];
}
- (void)initSubViews {
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(self);
    }];
}
- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.text = @" ";
        _titleLabel.textColor = SKColorWithHex(0x333333);
        _titleLabel.font = SKFONT_Medium(13);
        _titleLabel.textAlignment = NSTextAlignmentCenter;
        [self addSubview:_titleLabel];
    }
    return _titleLabel;
}
- (void)setTitle:(NSString *)title {
    _title = title;
    self.titleLabel.text = title;
}
@end
